import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './mypurse.css'
import { AtList, AtListItem, AtAccordion, AtGrid, AtButton } from "taro-ui"
import reactMixin from 'react-mixin';
import myJs from './mypurseJs.js'
import app from '../../../../main.js'

export default class MyPurse extends Component {

  config = {
    navigationBarTitleText: '我的钱包'
  }
  constructor () { 
        super(...arguments); 
        this.state = this.getData(); 
    }
    add(){
      app.navigateTo('../tianjiayinghangka/tianjiayinghangka')
    }
  // constructor() {
  //   super(...arguments)
  //   this.state = {
  //     open: false,
  //   }
  // }
  // onClick(value) {
  //   this.setState({
  //     open: value
  //   })
  // }
  // onClick2(value) {
  //   this.setState({
  //     open2: value
  //   })
  // }
  // state = {
  //   selector: ['美国', '中国', '巴西', '日本'],
  //   selectorChecked: '',
  //   timeSel: '',
  //   dateSel: ''
  // }
  // onChange = e => {
  //   this.setState({
  //     selectorChecked: this.state.selector[e.detail.value]
  //   },()=>{console.log(this.state.selectorChecked)})
  // }
  // onTimeChange = e => {
  //   this.setState({
  //     timeSel: e.detail.value
  //   })
  // }
  // onDateChange = e => {
  //   this.setState({
  //     dateSel: e.detail.value
  //   })
  // }
  init(){
    this.setState({
      open:true
    })
  }
  go(url) {
    app.navigateTo('../transactionrecord/transactionrecord')
  }
  
  //余额
  getNowBalance () {
    let me = this
    let data = {}
    app.post('web/wallet/getNowBalance', data, (res)=>{
      me.setState({
        balance:res.data.result.money
      })
    })
  }

  componentDidMount () {
    this.getNowBalance()
  }

  render() {
    const { balance } = this.state

    return (
      <View className='my-purse'>
        <View className='myMoney'>
            <View className='monText'>
                <Text className='text'>余额 （ 元 ）</Text>
            </View>
            <View className='nowMoney'><Text>￥ {balance}</Text></View>
        </View>
        <AtList hasBorder={true}>
          <AtListItem title='交易记录' onClick={this.go.bind(this)} arrow='right' hasBorder={false} className='list' />
          <AtListItem title='我的银行卡' onClick={this.add.bind(this)} arrow='right' hasBorder={false} className='list' />
        </AtList>
        {/* <View>
        <AtButton className='b' type='primary' onClick={this.add.bind(this)}>添加银行卡</AtButton>
        </View> */}
      </View>
    )
  }
}
reactMixin.onClass(MyPurse,myJs);
